package com.wjk.kylin.mall.product.beanmapper;

import com.wjk.kylin.mall.product.bo.ProductBO;
import com.wjk.kylin.mall.product.dto.ProductInDTO;
import com.wjk.kylin.mall.product.entity.ProductEntity;
import com.wjk.kylin.mall.product.entity.es.MallProductESBean;
import com.wjk.kylin.mall.product.entity.es.ProductESBean;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @Author: wangjinkui
 * @Date: 2021/5/28
 * @Description : 商品
 */
@Mapper
public interface ProductEntityMapper {
    ProductEntityMapper INSTANCE = Mappers.getMapper(ProductEntityMapper.class);

    /**
     * entity to bo
     *
     * @param entity
     * @return
     */
    @Mappings({
            @Mapping(source = "createTime", target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
    })
    ProductBO entity2BO(ProductEntity entity);

    /**
     * dto to entity
     *
     * @param dto
     * @return
     */
    ProductEntity dto2Entity(ProductInDTO dto);

    ProductESBean entity2ESBean(ProductEntity entity);

    void mEs2ESBean(MallProductESBean mallProductESBean, @MappingTarget ProductESBean esBean);
}
